#include "trap.h"
#include "inst_test.h"
#include "asm/regdef.h"
#include "asm/asm.h"
    .set noreorder
    .set noat 
    .global main 
    .text 

main:
    # 初始化
    ori $t0, $zero, 5           # $t0 = 5
    ori $t1, $zero, 10          # $t1 = 10

    # 数据相关性操作
    add $t2, $t0, $t1           # $t2 = $t0 + $t1
    sub $t3, $t2, $t0           # $t3 = $t2 - $t0 (使用$t2结果)
    and $t4, $t3, $t1           # $t4 = $t3 & $t1 (使用$t3结果)
    or $t5, $t4, $t2            # $t5 = $t4 | $t2 (使用$t4和$t2结果)

    # 检查前推逻辑
    xor $t6, $t5, $t0           # $t6 = $t5 ^ $t0
    sll $t7, $t6, 2             # $t7 = $t6 << 2
    addu $t8, $t7, $t1          # $t8 = $t7 + $t1

    # 循环测试
    ori $s0, $zero, 3           # $s0 = 3 (循环计数器)
loop1:
    sub $s0, $s0, 1             # $s0 -= 1
    add $t9, $t8, $s0           # $t9 = $t8 + $s0
    bne $s0, $zero, loop1       # 如果$s0 != 0，跳回loop1
    nop                         # 延迟槽


    HIT_GOOD_TRAP

inst_error:
    HIT_BAD_TRAP